
#agents
players = ['greedyscore', 'greedysmartscore', 'greedymob', 'greedystab', 'naive', 'scoremax', 'smartscoremax', 'mobimax', 'mobiplus', 'stabmax', 'mobstab', 'most', 'scoreab', 'smartscoreab', 'mobab', 'mobplusab', 'stabab', 'mobstabab', 'mostab']
heuristics = {'score' : ['greedyscore', 'scoremax', 'scoreab'],
	      'smartscore' : ['greedysmartscore', 'smartscoremax', 'smartscoreab'],
	      'mobility' : ['greedymob', 'mobimax', 'mobab'],
	      'stability' : ['greedystab', 'stabmax', 'stabab']}

stats = open('stats.txt','w')

for player in players:
	stats.write(player)
	win = 0
	loss = 0
	tie = 0
	#random plays as black
	out = open('random-Vs-%s-100.txt'%player)
	for line in out:
		if line[:5] == "Black":
			loss += 1
		elif line[:5] == "White":
			win += 1
		elif line[:3] == "Tie":
			tie += 1
	out.close()
	out = open('%s-Vs-random-100.txt'%player)
	for line in out:
		if line[:5] == "Black":
			win += 1
		elif line[:5] == "White":
			loss += 1
		elif line[:3] == "Tie":
			tie += 1
	out.close()
	stats.write('\twon: %d lost: %d tied: %d\n' % (win, loss, tie))

stats.write('\n\n\n\n\n')

for h, a in heuristics.iteritems():
	stats.write(h + '\n')
	for agent in a:
		win = 0
		loss = 0
		tie = 0
		stats.write(agent)
		for other in a:
			if(agent != other):
				out = open('%s-Vs-%s-500.txt'%(other, agent))
				for line in out:
					if line[:5] == "Black":
						loss += 1
					elif line[:5] == "White":
						win += 1
					elif line[:3] == "Tie":
						tie += 1
				out.close()
				out = open('%s-Vs-%s-500.txt'%(agent, other))
				for line in out:
					if line[:5] == "Black":
						win += 1
					elif line[:5] == "White":
						loss += 1
					elif line[:3] == "Tie":
						tie += 1
				out.close()
		stats.write('\twon: %d lost: %d tied: %d\n' % (win, loss, tie))
stats.close()